{include file='/public/header'}
  <body>
    <div class="x-body">
        <form class="layui-form">
        <input type="hidden" name="id" value="{$data.id}">
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>手术人名
              </label>
              <div class="layui-input-inline">
                  <input type="text" name="title" value="{$data.title}" placeholder="请输入手术人名" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">手术人图片</label>
            <div class="layui-input-inline">
              <button type="button" class="layui-btn" id="test1" onclick="return false;">
              <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <hr class="hr15">
            <img id="pic" <?php if($data['pic']){echo 'src="'.$data['pic'].'"';}?>>
            <input type="hidden" name="pic" value="{$data.pic}">
            </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>效果
              </label>
              <div class="layui-input-block">
                  <input type="text" name="good" value="{$data.good}" placeholder="请输入手术后的效果" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">手术简介</label>
              <div class="layui-input-block">
                  <textarea type="text" name="content" id="EditorId">{$data.content}</textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>类别
              </label>
              <div class="layui-input-inline">
                  <select name="gid">
                      <option value="0">--请选择--</option>
                      {volist name="atrr" id='vo'}
                      <option value="{$vo.id}" <?php if($data['gid']==$vo['id']){echo 'selected';}?>>{$vo.name}</option>
                      {/volist}
                  </select>
              </div>
          </div>
      </form>
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" onclick="save()">保存</button>
        </div>
      </div>
    </div>
    <script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.all.min.js"> </script>
    <script>
        layui.use(['form','layer','upload'], function(){
            form = layui.form;
            layer = layui.layer;
            $ = layui.jquery;
            var upload = layui.upload;

            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                ,url: '{:url("team/upload_img")}' //上传接口
                ,accept:'images'
                ,done: function(res){
                  //上传完毕回调
                  $('#pic').attr('src',res.msg);
                  $('input[name="pic"]').val(res.msg);
                }
                ,error: function(){
                  //请求异常回调
                }
            });
        });
        //保存
        function save(){
          var title = $.trim($('input[name="title"]').val());
          var good = $.trim($('input[name="good"]').val());
          var gid = $.trim($('select[name="gid"]').val());
          var content = $.trim($('textarea[name="content"]').val());

          if(title == ''){
            layer.msg('请填写手术人名',{'icon':2,'anim':6});
            return;
          }
          if(good == ''){
            layer.msg('请填写手术效果',{'icon':2,'anim':6});
            return;
          }
          if(content == ''){
            layer.msg('请填写医生简介',{'icon':2,'anim':6});
          }
          if(gid == '0'){
            layer.msg('请选择手术类别',{'icon':2,'anim':6});
            return;
          }
          $.post('{:url("change/diary_save")}',$('form').serialize(),function(res){
            if(res.code>0){
              layer.msg(res.msg,{'icon':2,'anim':2});
            }else{
              layer.msg(res.msg,{'icon':1});
              setTimeout(function(){parent.window.location.reload();},1000);
            }
          },'json');
        }

        window.UEDITOR_HOME_URL = "__STATIC__/ueditor/";//配置路径设定为UEditor所放的位置
         window.onload=function(){
            window.UEDITOR_CONFIG.initialFrameHeight=300;//编辑器的高度
            window.UEDITOR_CONFIG.initialFrameWidth=848;//编辑器的宽度
            var editor = new UE.ui.Editor({
                
            });
            editor.render("EditorId");//此处的EditorId与<textarea name="content" id="EditorId">的id值对应 </textarea>
        }
    </script>
  </body>

</html>